import Cookies from "js-cookie";

export const setCookie = (key: string, value: string) => {
  if(typeof value === 'object') {
    value = JSON.parse(value)
  }
  Cookies.set(key, value) 
}

export const getCookie = (key: string) => {
  const data = (Cookies.get(key)) as string
  try {
    return JSON.parse(data)    
  } catch (error) {
    return data
  }
}

export const removeCookie = (key: string) => {
  Cookies.remove(key)
}